<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>登录</title>
    <script src="//g.alicdn.com/dingding/dinglogin/0.0.5/ddLogin.js"></script>
    <!--<script src="http://g.alicdn.com/dingding/dingtalk-pc-api/2.7.0/index.js"></script>-->
    <script src="http://g.alicdn.com/dingding/dingtalk-jsapi/2.3.0/dingtalk.open.js"></script>
</head>
<body>
<div class="loginBg">
    <div class="leftImgIcon"></div>
    <div class="leftImgWord"></div>
    <div class="login">
        <a href="dingtalk://dingtalkclient/action/sendmsg?dingtalk_id=x770212572">跳转客户端</a>
        <div class="loginBox">
            <h2 id='tit'><a href="javascript:void(0);" class='active codeBtn' onclick="goCode()">扫码登录</a></h2>
            <!-- <a href="javascript:void(0);" class="passwordBtn" onclick="goPassword()">账号登录</a> -->
            <main style="height:289px">
                <div class="code">
                    <div id="login_container"></div>
                </div>
                <!-- <iframe class="password" src="https://login.dingtalk.com/login/index.htm?goto=https%3A%2F%2Foapi.dingtalk.com%2Fconnect%2Foauth2%2Fsns_authorize%3Fappid%3Ddingoacjvh3huyegtq9kbz%26response_type%3Dcode%26scope%3Dsnsapi_login%26state%3DSTATE%26redirect_uri=http://nanj.ngrok.xiaomiqiu.cn/routers/login" frameborder="0"></iframe> -->
            </main>
        </div>
    </div>
</div>
<div class="loginFoot">
    <p>徐某人科技股份有限公司</p>
</div>
</body>
<script>
    var config = {};
    var agentId = '';
    var corpId = '';
    var timeStamp = '';
    var nonceStr = '';
    var signature = '';
    $.ajax({
        url: "/api/authorityManage/getConfig",
        type: "get",
        async: false,
        dataType: "json",
        success:function(data){
            console.log(data)
            if(data.status == '0'){
                // config = data.config;
                agentId = data.config.agentId;
                corpId = data.config.corpId;
                timeStamp = data.config.timeStamp;
                nonceStr = data.config.nonceStr;
                signature = data.config.signature;
            }
        }
    })


    //PC端 DingTalkPC暂且不能实现
    // DingTalkPC.config({
    //     agentId: agentId, // 必填，微应用ID
    //     corpId: corpId,//必填，企业ID
    //     timeStamp: timeStamp, // 必填，生成签名的时间戳
    //     nonceStr: nonceStr, // 必填，生成签名的随机串
    //     signature: signature, // 必填，签名
    //     type:0,
    //     jsApiList: ['device.notification.alert', 'device.notification.confirm'] // 必填，需要使用的jsapi列表
    // });
    //
    // DingTalkPC.ready(function(res){
    //     alert("success");
    // });
    //
    // DingTalkPC.error(function(error){
    //     alert("error");
    // });


    dd.config({
        agentId: agentId, // 必填，微应用ID
        corpId: corpId,//必填，企业ID
        timeStamp: timeStamp, // 必填，生成签名的时间戳
        nonceStr: nonceStr, // 必填，生成签名的随机串
        signature: signature, // 必填，签名
        type:0,   //选填，0表示微应用的jsapi，1表示服务窗的jsapi，不填默认为0。该参数从dingtalk.js的0.8.3版本开始支持
        jsApiList : [ 'biz.cspace.saveFile', 'biz.cspace.chooseSpaceDir',
            'device.notification.confirm', 'device.notification.alert',
            'device.notification.prompt', 'biz.ding.post',
            'biz.util.openLink' ] // 必填，需要使用的jsapi列表，注意：不要带dd。
    });

    dd.ready(function() {
        dd.device.notification.confirm({
            message: "你爱我吗",
            title: "提示",
            buttonLabels: ['爱', '不爱'],
            onSuccess: function (result) {
                alert("success");
            },
            onFail: function (err) {
                alert("filed");
            }

        });
    })

    // dd.biz.cspace.saveFile({
    //     corpId:"ding7ef688a4924e128335c2f4657eb6378f",
    //     url:"http://bj-oss-d-shujiajia.oss-cn-beijing.aliyuncs.com/dataworks/weekReport/1545915597665_项目指派.docx?Expires=4102329599&OSSAccessKeyId=LTAIER3YM8cdW2yI&Signature=Uc0TUy1sdaO5A5V9ThNmLh9edew=",  // 文件在第三方服务器地址
    //     name:"文件名",
    //     onSuccess: function(data) {
    //         alert(JSON.stringify(data));
    //         finsh(JSON.stringify(data));
    //     },
    //     onFail: function(err) {
    //         alert(JSON.stringify(err));
    //         finsh(JSON.stringify(err));
    //     }
    // });


    // dd.biz.cspace.chooseSpaceDir({
    //     corpId:"ding7ef688a4924e128335c2f4657eb6378f",
    //     onSuccess: function(data) {
    //         alert(JSON.stringify(data));
    //         finsh(JSON.stringify(data));
    //     },
    //     onFail: function(err) {
    //         alert(JSON.stringify(err));
    //         finsh(JSON.stringify(err));
    //     }
    // });


    //     dd.runtime.permission.requestAuthCode({
    //         corpId: "ding7ef688a4924e128335c2f4657eb6378f",
    //         onSuccess: function(data) {
    //             alert(JSON.stringify(data));
    //             finsh(JSON.stringify(data));
    //         },
    //         onFail : function(err) {
    //             alert(JSON.stringify(err));
    //             finsh(JSON.stringify(err));
    //         }
    //
    //     })
    //
    //     // 5fd88ee630dc3c43a9eef6252bea77f0
    // });



    function finsh(str) {
        $.ajax({
            url: "/api/authorityManage/getConfig?finsh="+str,
            type: "get",
            dataType: "json",
            success: function (data) {
                alert(data);
            }
        })
    }
</script>
<script src="login.js"></script>
</html>